package com.ruoyi.religon.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.religon.domain.WmsWarehouseRegion;
import com.ruoyi.religon.service.IWmsWarehouseRegionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库区信息Controller
 * 
 * @author 董熠涛
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/religion/religion")
public class WmsWarehouseRegionController extends BaseController
{
    @Autowired
    private IWmsWarehouseRegionService wmsWarehouseRegionService;

    /**
     * 查询库区信息列表
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsWarehouseRegion wmsWarehouseRegion)
    {
        startPage();
        List<WmsWarehouseRegion> list = wmsWarehouseRegionService.selectWmsWarehouseRegionList(wmsWarehouseRegion);
        return getDataTable(list);
    }

    /**
     * 导出库区信息列表
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:export')")
    @Log(title = "库区信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehouseRegion wmsWarehouseRegion)
    {
        List<WmsWarehouseRegion> list = wmsWarehouseRegionService.selectWmsWarehouseRegionList(wmsWarehouseRegion);
        ExcelUtil<WmsWarehouseRegion> util = new ExcelUtil<WmsWarehouseRegion>(WmsWarehouseRegion.class);
        util.exportExcel(response, list, "库区信息数据");
    }

    /**
     * 获取库区信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsWarehouseRegionService.selectWmsWarehouseRegionById(id));
    }

    /**
     * 新增库区信息
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:add')")
    @Log(title = "库区信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsWarehouseRegion wmsWarehouseRegion)
    {
        return toAjax(wmsWarehouseRegionService.insertWmsWarehouseRegion(wmsWarehouseRegion));
    }

    /**
     * 修改库区信息
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:edit')")
    @Log(title = "库区信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsWarehouseRegion wmsWarehouseRegion)
    {
        return toAjax(wmsWarehouseRegionService.updateWmsWarehouseRegion(wmsWarehouseRegion));
    }

    /**
     * 删除库区信息
     */
    @PreAuthorize("@ss.hasPermi('religion:religion:remove')")
    @Log(title = "库区信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsWarehouseRegionService.deleteWmsWarehouseRegionByIds(ids));
    }
}
